package com.chinasoft.ssm.service.impl;

import com.chinasoft.ssm.mapper.AdminInfoMapper;
import com.chinasoft.ssm.mapper.UserInfoMapper;
import com.chinasoft.ssm.pojo.Admin;
import com.chinasoft.ssm.pojo.User;
import com.chinasoft.ssm.service.AdminService;
import com.chinasoft.ssm.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class AdminServiceImpl implements AdminService {

    @Autowired
    AdminInfoMapper mapper;

    @Override
    public Boolean login(String name, String password) {
        Admin info = mapper.selectByName(name);

        // 数据查询不到
        if (info == null) {
            log.info("cheng11");
            return false;
        }
        // 比较密码
        if (password.equals(info.getPassword())) {
            log.info("chengg");
            return true;
        } else {
            log.info("cheng");
            return false;
        }
    }

    @Override
    public Boolean changePW(String username, String password) {
        return null;
    }

    @Override
    public List<Admin> selectAll() {
        return mapper.selectall();
    }

    @Override
    public Admin selectone(String name) {
        return mapper.selectByName(name);
    }

    @Override
    public Admin selectById(int id) {
        return mapper.selectById(id);
    }

    @Override
    public Integer update(Admin admin) {
        return mapper.update(admin);
    }

    @Override
    public Admin login1(String name) {
        return mapper.selectByName(name);
    }


}
